Skip to content

fix: optimize regressions from editions implementations #2066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 8, 2025

Conversation

mkruskal-google
Copy link
Contributor

@mkruskal-google mkruskal-google commented May 7, 2025

This PR contains 4 optimizations:

  1. Instead of using resolved type information for feature resolution, we can use a more rudimentary approach. This was only being used to detect legacy groups, which are always in a very predictable location that's easy and efficient to lookup. Instead of forcing full type resolution of the entire graph, this change reduces the calls to only do feature resolution, which is very lightweight in comparison.

  2. Cache the feature resolution state at the namespace level to avoid repeated calculations. Unless new objects are added, every object should only need to do feature resolution once.

  3. As highlighted in Namespace lookup performance far worse than O(N) #2064, lookup is wildly inefficient and profiling shows that it eats up most of the cpu costs for resolveAll. We add some basic caching capabilities and reduce unnecessary recursion to avoid duplicate work, which shows up to a 30x speedup resolving a very large proto (from 3s to 0.1s).

  4. A bug was introduced during the development of editions in ReflectionObject.resolve that essentially disabled all caching of resolved type information. Restoring this means that repeated calls to resolveAll should only force the rebuild of invalidated or unresolved objects, rather than the entire tree.

This PR just captures the low hanging fruit to unblock the launch of editions support. There are likely many further optimizations that could be applied to both feature resolution and lookup.

Fixes #2063

@mkruskal-google mkruskal-google requested a review from sofisl May 7, 2025 02:43
@mkruskal-google mkruskal-google changed the title fix: remove unnecessary calls to resolveAll fix: post-editions optimizations May 8, 2025
@mkruskal-google mkruskal-google changed the title fix: post-editions optimizations fix: optimize regressions from editions implementations May 8, 2025
@sofisl sofisl merged commit 6406d4c into master May 8, 2025
6 checks passed
@github-actions github-actions bot mentioned this pull request May 7, 2025
@mkruskal-google mkruskal-google deleted the optimize-resolve branch May 8, 2025 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Large performance regression in Root.load & loadSync in 7.5.0
2 participants